/**
  ******************************************************************************
  * Copyright (c) 2019 - ~, SCUT-RobotLab Development Team
  * @file    sys_support_timer.h
  * @author  Mentos_Seetoo 1356046979@qq.com 
	*					 M3chD09 			 rinngo17@foxmail.com
	*					 CuiQQ				 860241578@qq.com
  * @brief   Code for Timer Management in STM32 series MCU, supported packaged:
  *          - STM32Cube_FW_F4_V1.24.0.
  *          - STM32Cube_FW_F1_V1.8.0.
  *          - STM32Cube_FW_H7_V1.5.0.
  * @date    2019-06-12
  * @version 3.0
  * @par Change Log：
  * <table>
  * <tr><th>Date        <th>Version  <th>Author         <th>Description
  * <tr><td>2019-06-12  <td> 1.0     <td>Mentos Seetoo  <td>Creator
  * <tr><td>2019-10-28  <td> 2.0     <td>Mentos Seetoo  <td>Add Timer manage object.
  * <tr><td>2021-04-06  <td> 3.0     <td>M3chD09        <td>Remove HAL_TIM_Base_Start in Timer_Init.
  * </table>
  *
  ==============================================================================
                            How to use this driver  
  ==============================================================================
    @note
      -# 使用`Timer_Init()`设置延时定时器`TIM_X`,设置`delay_ms()`函数使用HAL库的实现
          `HAL_Delay()`或使用模块内方法实现。		
      -# 配置`TIM_X`自增时间为1us，在对应中断函数中加入:`Update_SystemTick();`。
      -# 在需要延时的地方使用`delay_us_nos()`或`Delay_ms()`。
		
    @warning
      -# 本模块的所有延时函数均为堵塞式延时。
      -# 使用前必须进行初始化！
      -# 添加预编译宏`USE_FULL_ASSERT`可以启用断言检查。
  ******************************************************************************
  * @attention
  * 
  * if you had modified this file, please make sure your code does not have any 
  * bugs, update the version Number, write dowm your name and the date. The most
  * important thing is make sure the users will have clear and definite under-
  * standing through your new brief.
  *
  * <h2><center>&copy; Copyright (c) 2019 - ~, SCUT-RobotLab Development Team.
  * All rights reserved.</center></h2>
  ******************************************************************************
  */

#ifndef  _SYS_SUPPORT_TIMER_H
#define  _SYS_SUPPORT_TIMER_H

#ifdef  __cplusplus
extern "C"{
#endif

/* Includes ------------------------------------------------------------------*/
#include "stm32fxxx_hal.h"

/* Exported macros -----------------------------------------------------------*/
/* Exported types ------------------------------------------------------------*/
typedef enum 
{
	USE_MODULE_DELAY = 1,	/*!< Use module function to implement Delay_ms()*/
	USE_HAL_DELAY			/*!< Use HAL_Delay() for Delay_ms()*/
}EDelay_src;

/* Exported variables ---------------------------------------------------------*/

/* Exported function declarations --------------------------------------------*/
void Timer_Init(TIM_HandleTypeDef* htim, EDelay_src src);
void Update_SystemTick(void);
uint64_t Get_SystemTimer_us(void);
uint64_t Get_SystemTimer_ms(void);
void Delay_ms(uint32_t cnt);
void Delay_us(uint32_t cnt);


#ifdef  __cplusplus
}
#endif

#endif 
/************************ COPYRIGHT(C) SCUT-ROBOTLAB **************************/
